<template>
    <div class="app">
        <div class="search"><input type="search" v-model="search" placeholder="请输入搜索条件">
            <div class="btn" @click="tosearch()"><img src="/static/images/search.png"/></div>
        </div>
        <!--<swiper class='slide' autoplay="true" interval='5000' indicator-dots='true'>-->
        <!--<swiper-item v-for="(item,index) in slide_list" :key="index">-->
            <!--<image class='slide-image' :src="resurl+item.pic+'?x-oss-process=image/resize,m_fill,w_750,h_300'"-->
                   <!--mode="aspectFill"/>-->
        <!--</swiper-item>-->
    <!--</swiper>-->
        <swiper class='slide' autoplay="true" interval='5000' indicator-dots='true' :href="link">
            <swiper-item v-for="(item,index) in slide_list" :key="index">
                <a :href="item.link">
                    <image class='slide-image'  :src="resurl+item.pic+'?x-oss-process=image/resize,m_fill,w_750,h_300'"
                           mode="aspectFill"/>
                </a>
            </swiper-item>
        </swiper>
        <div class="new_list">
            <div class="box_title">最新作品</div>
            <div class="content">
                <a v-for="(item,index) in new_list" :key="index" class="item"
                   :href="'/pages/writing/index/main?code='+item.code">
                    <div class="info">
                        <img class='photo' :src="resurl+item.photo+'?x-oss-process=image/resize,m_fill,w_360,h_540'"
                             mode="aspectFill"/>
                        <div class="bottom">
                            <div class="text title">作品名称:{{item.title}}</div>
                            <div class="text code">作品编号:{{item.code}}</div>
                            <div class="text name">选手姓名:{{item.name}}</div>
                            <div class="text teacher">指导教师:{{item.teacher}}</div>
                        </div>
                        <div class="pay_btn" v-if="item.status==0" @click="pay(item.orderno)">付款</div>
                    </div>
                </a>
            </div>
        </div>
    </div>
</template>

<script>
    var that = null
    export default {
        data() {
            return this.datainit({
                search: "",
                slide_list: [],
                new_list: [],
            })
        },
        onShow() {
            that = this
            that.check()
        },
        methods: {
            init() {
                that.$post("api/index/slide", null, function (list) {
                    that.slide_list = list
                })
                that.$post("api/writing/new_lists", null, function (list) {
                    that.new_list = list
                })
            },
            tosearch() {
                if (that.search == "") {
                    that.toast("请输入搜索内容");
                    return;
                }
                wx.navigateTo({
                    url: "/pages/writing/list/main?search=" + that.search
                })
            }
        },
        onShareAppMessage(res) {
            return {
                title: "曹灿杯",
                path: '/pages/index/index/main'
            }
        }

    }
</script>

<style scoped lang="less">
    .slide {
        position: relative;
        width: 100%;
        height: 150px;
        a{
            width: 100%;
            height:100%;
            image {
                width: 100%;
                height: 100%;
            }
        }

    }

    .search {
        position: relative;
        width: 100%;
        box-sizing: border-box;
        border-left: 10px solid #FFF;
        border-right: 10px solid #FFF;
        background: #FFF;
        height: 50px;
        padding-top: 5px;
        display: flex;

        input {
            flex: 1;
            border-radius: 5px;
            border: 1px solid #CCC;
            height: 38px;
        }

        .btn {
            display: block;
            width: 50px;
            height: 40px;

            img {
                position: relative;
                display: block;
                width: 30px;
                height: 30px;
                margin: auto;
                margin-top: 5px;
            }
        }

    }

    .new_list {
        position: relative;
        width: 100%;
        background: #FFF;
        margin-top: 10px;

        .box_title {
            position: relative;
            text-align: center;
            line-height: 40px;
        }

        .content {
            position: relative;
            overflow: hidden;

            .item {
                position: relative;
                width: 180px;
                overflow: hidden;
                float: left;
                background: #FFF;
                margin: 3.75px;

                .photo {
                    display: block;
                    width: 160px;
                    height: 240px;
                    margin: auto;
                    margin-top: 10px;

                }

                .bottom {
                    width: 160px;
                    margin: auto;
                    font-size: 14px;
                    color: #999;
                    margin: auto;
                    line-height: 20px;
                    height: 80px;

                    .text {
                        overflow: hidden;
                        text-overflow: ellipsis;
                        white-space: nowrap;
                    }
                }
            }

            .item:nth-child(2n) {
                margin-right: 0 !important;
            }
        }
    }

</style>
